<!DOCTYPE HTML>
<html lang="zh-CN">


<head>
    <meta charset="utf-8">
    <meta name="keywords" content="封装的JS工具类整理, 一米阳光-博客">
    <meta name="description" content="">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no">
    <meta name="renderer" content="webkit|ie-stand|ie-comp">
    <meta name="mobile-web-app-capable" content="yes">
    <meta name="format-detection" content="telephone=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
    <!-- Global site tag (gtag.js) - Google Analytics -->


    <title>封装的JS工具类整理 | 一米阳光-博客</title>
    <link rel="icon" type="image/png" href="/jack-blog/favicon.png">

    <link rel="stylesheet" type="text/css" href="/jack-blog/libs/awesome/css/all.css">
    <link rel="stylesheet" type="text/css" href="/jack-blog/libs/materialize/materialize.min.css">
    <link rel="stylesheet" type="text/css" href="/jack-blog/libs/aos/aos.css">
    <link rel="stylesheet" type="text/css" href="/jack-blog/libs/animate/animate.min.css">
    <link rel="stylesheet" type="text/css" href="/jack-blog/libs/lightGallery/css/lightgallery.min.css">
    <link rel="stylesheet" type="text/css" href="/jack-blog/css/matery.css">
    <link rel="stylesheet" type="text/css" href="/jack-blog/css/my.css">

    <script src="/jack-blog/libs/jquery/jquery.min.js"></script>

<meta name="generator" content="Hexo 5.3.0"></head>




<body>
    <header class="navbar-fixed">
    <nav id="headNav" class="bg-color nav-transparent">
        <div id="navContainer" class="nav-wrapper container">
            <div class="brand-logo">
                <a href="/jack-blog/" class="waves-effect waves-light">
                    
                    <img src="/jack-blog/medias/logo.png" class="logo-img" alt="LOGO">
                    
                    <span class="logo-span">一米阳光-博客</span>
                </a>
            </div>
            

<a href="#" data-target="mobile-nav" class="sidenav-trigger button-collapse"><i class="fas fa-bars"></i></a>
<ul class="right nav-menu">
  
  <li class="hide-on-med-and-down nav-item">
    
    <a href="/jack-blog/" class="waves-effect waves-light">
      
      <i class="fas fa-home" style="zoom: 0.6;"></i>
      
      <span>首页</span>
    </a>
    
  </li>
  
  <li class="hide-on-med-and-down nav-item">
    
    <a href="/jack-blog/tags" class="waves-effect waves-light">
      
      <i class="fas fa-tags" style="zoom: 0.6;"></i>
      
      <span>标签</span>
    </a>
    
  </li>
  
  <li class="hide-on-med-and-down nav-item">
    
    <a href="/jack-blog/categories" class="waves-effect waves-light">
      
      <i class="fas fa-bookmark" style="zoom: 0.6;"></i>
      
      <span>分类</span>
    </a>
    
  </li>
  
  <li class="hide-on-med-and-down nav-item">
    
    <a href="/jack-blog/archives" class="waves-effect waves-light">
      
      <i class="fas fa-archive" style="zoom: 0.6;"></i>
      
      <span>归档</span>
    </a>
    
  </li>
  
  <li class="hide-on-med-and-down nav-item">
    
    <a href="/jack-blog/about" class="waves-effect waves-light">
      
      <i class="fas fa-user-circle" style="zoom: 0.6;"></i>
      
      <span>关于</span>
    </a>
    
  </li>
  
  <li class="hide-on-med-and-down nav-item">
    
    <a href="/jack-blog/contact" class="waves-effect waves-light">
      
      <i class="fas fa-comments" style="zoom: 0.6;"></i>
      
      <span>留言板</span>
    </a>
    
  </li>
  
  <li class="hide-on-med-and-down nav-item">
    
    <a href="/jack-blog/friends" class="waves-effect waves-light">
      
      <i class="fas fa-address-book" style="zoom: 0.6;"></i>
      
      <span>友情链接</span>
    </a>
    
  </li>
  
  <li>
    <a href="#searchModal" class="modal-trigger waves-effect waves-light">
      <i id="searchIcon" class="fas fa-search" title="搜索" style="zoom: 0.85;"></i>
    </a>
  </li>
</ul>


<div id="mobile-nav" class="side-nav sidenav">

    <div class="mobile-head bg-color">
        
        <img src="/jack-blog/medias/logo.png" class="logo-img circle responsive-img">
        
        <div class="logo-name">一米阳光-博客</div>
        <div class="logo-desc">
            
            Never really desperate, only the lost of the soul.
            
        </div>
    </div>

    

    <ul class="menu-list mobile-menu-list">
        
        <li class="m-nav-item">
	  
		<a href="/jack-blog/" class="waves-effect waves-light">
			
			    <i class="fa-fw fas fa-home"></i>
			
			首页
		</a>
          
        </li>
        
        <li class="m-nav-item">
	  
		<a href="/jack-blog/tags" class="waves-effect waves-light">
			
			    <i class="fa-fw fas fa-tags"></i>
			
			标签
		</a>
          
        </li>
        
        <li class="m-nav-item">
	  
		<a href="/jack-blog/categories" class="waves-effect waves-light">
			
			    <i class="fa-fw fas fa-bookmark"></i>
			
			分类
		</a>
          
        </li>
        
        <li class="m-nav-item">
	  
		<a href="/jack-blog/archives" class="waves-effect waves-light">
			
			    <i class="fa-fw fas fa-archive"></i>
			
			归档
		</a>
          
        </li>
        
        <li class="m-nav-item">
	  
		<a href="/jack-blog/about" class="waves-effect waves-light">
			
			    <i class="fa-fw fas fa-user-circle"></i>
			
			关于
		</a>
          
        </li>
        
        <li class="m-nav-item">
	  
		<a href="/jack-blog/contact" class="waves-effect waves-light">
			
			    <i class="fa-fw fas fa-comments"></i>
			
			留言板
		</a>
          
        </li>
        
        <li class="m-nav-item">
	  
		<a href="/jack-blog/friends" class="waves-effect waves-light">
			
			    <i class="fa-fw fas fa-address-book"></i>
			
			友情链接
		</a>
          
        </li>
        
        
        <li><div class="divider"></div></li>
        <li>
            <a href="https://github.com/sunshinehome" class="waves-effect waves-light" target="_blank">
                <i class="fab fa-github-square fa-fw"></i>Fork Me
            </a>
        </li>
        
    </ul>
</div>


        </div>

        
            <style>
    .nav-transparent .github-corner {
        display: none !important;
    }

    .github-corner {
        position: absolute;
        z-index: 10;
        top: 0;
        right: 0;
        border: 0;
        transform: scale(1.1);
    }

    .github-corner svg {
        color: #0f9d58;
        fill: #fff;
        height: 64px;
        width: 64px;
    }

    .github-corner:hover .octo-arm {
        animation: a 0.56s ease-in-out;
    }

    .github-corner .octo-arm {
        animation: none;
    }

    @keyframes a {
        0%,
        to {
            transform: rotate(0);
        }
        20%,
        60% {
            transform: rotate(-25deg);
        }
        40%,
        80% {
            transform: rotate(10deg);
        }
    }
</style>

<a href="https://github.com/sunshinehome" class="github-corner tooltipped hide-on-med-and-down" target="_blank"
   data-tooltip="Fork Me" data-position="left" data-delay="50">
    <svg viewBox="0 0 250 250" aria-hidden="true">
        <path d="M0,0 L115,115 L130,115 L142,142 L250,250 L250,0 Z"></path>
        <path d="M128.3,109.0 C113.8,99.7 119.0,89.6 119.0,89.6 C122.0,82.7 120.5,78.6 120.5,78.6 C119.2,72.0 123.4,76.3 123.4,76.3 C127.3,80.9 125.5,87.3 125.5,87.3 C122.9,97.6 130.6,101.9 134.4,103.2"
              fill="currentColor" style="transform-origin: 130px 106px;" class="octo-arm"></path>
        <path d="M115.0,115.0 C114.9,115.1 118.7,116.5 119.8,115.4 L133.7,101.6 C136.9,99.2 139.9,98.4 142.2,98.6 C133.8,88.0 127.5,74.4 143.8,58.0 C148.5,53.4 154.0,51.2 159.7,51.0 C160.3,49.4 163.2,43.6 171.4,40.1 C171.4,40.1 176.1,42.5 178.8,56.2 C183.1,58.6 187.2,61.8 190.9,65.4 C194.5,69.0 197.7,73.2 200.1,77.6 C213.8,80.2 216.3,84.9 216.3,84.9 C212.7,93.1 206.9,96.0 205.4,96.6 C205.1,102.4 203.0,107.8 198.3,112.5 C181.9,128.9 168.3,122.5 157.7,114.1 C157.9,116.9 156.7,120.9 152.7,124.9 L141.0,136.5 C139.8,137.7 141.6,141.9 141.8,141.8 Z"
              fill="currentColor" class="octo-body"></path>
    </svg>
</a>
        
    </nav>

</header>

    



<div class="bg-cover pd-header post-cover" style="background-image: url('/jack-blog/medias/featureimages/18.jpg')">
    <div class="container" style="right: 0px;left: 0px;">
        <div class="row">
            <div class="col s12 m12 l12">
                <div class="brand">
                    <h1 class="description center-align post-title">封装的JS工具类整理</h1>
                </div>
            </div>
        </div>
    </div>
</div>




<main class="post-container content">

    
    <link rel="stylesheet" href="/jack-blog/libs/tocbot/tocbot.css">
<style>
    #articleContent h1::before,
    #articleContent h2::before,
    #articleContent h3::before,
    #articleContent h4::before,
    #articleContent h5::before,
    #articleContent h6::before {
        display: block;
        content: " ";
        height: 100px;
        margin-top: -100px;
        visibility: hidden;
    }

    #articleContent :focus {
        outline: none;
    }

    .toc-fixed {
        position: fixed;
        top: 64px;
    }

    .toc-widget {
        width: 345px;
        padding-left: 20px;
    }

    .toc-widget .toc-title {
        padding: 35px 0 15px 17px;
        font-size: 1.5rem;
        font-weight: bold;
        line-height: 1.5rem;
    }

    .toc-widget ol {
        padding: 0;
        list-style: none;
    }

    #toc-content {
        padding-bottom: 30px;
        overflow: auto;
    }

    #toc-content ol {
        padding-left: 10px;
    }

    #toc-content ol li {
        padding-left: 10px;
    }

    #toc-content .toc-link:hover {
        color: #42b983;
        font-weight: 700;
        text-decoration: underline;
    }

    #toc-content .toc-link::before {
        background-color: transparent;
        max-height: 25px;

        position: absolute;
        right: 23.5vw;
        display: block;
    }

    #toc-content .is-active-link {
        color: #42b983;
    }

    #floating-toc-btn {
        position: fixed;
        right: 15px;
        bottom: 76px;
        padding-top: 15px;
        margin-bottom: 0;
        z-index: 998;
    }

    #floating-toc-btn .btn-floating {
        width: 48px;
        height: 48px;
    }

    #floating-toc-btn .btn-floating i {
        line-height: 48px;
        font-size: 1.4rem;
    }
</style>
<div class="row">
    <div id="main-content" class="col s12 m12 l9">
        <!-- 文章内容详情 -->
<div id="artDetail">
    <div class="card">
        <div class="card-content article-info">
            <div class="row tag-cate">
                <div class="col s7">
                    
                    <div class="article-tag">
                        
                            <a href="/jack-blog/tags/js/">
                                <span class="chip bg-color">js</span>
                            </a>
                        
                    </div>
                    
                </div>
                <div class="col s5 right-align">
                    
                    <div class="post-cate">
                        <i class="fas fa-bookmark fa-fw icon-category"></i>
                        
                            <a href="/jack-blog/categories/%E5%89%8D%E7%AB%AF/" class="post-category">
                                前端
                            </a>
                        
                    </div>
                    
                </div>
            </div>

            <div class="post-info">
                
                <div class="post-date info-break-policy">
                    <i class="far fa-calendar-minus fa-fw"></i>发布日期:&nbsp;&nbsp;
                    2021-03-04
                </div>
                

                

                

                

                
            </div>
        </div>
        <hr class="clearfix">

        

        

        <div class="card-content article-card-content">
            <div id="articleContent">
                <p>1.邮箱</p>
<p>export const isEmail = (s) =&gt; {<br>    return /^([a-zA-Z0-9_-])+@([a-zA-Z0-9_-])+((.[a-zA-Z0-9_-]{2,3}){1,2})$/.test(s)<br>}<br>2.手机号码</p>
<p>export const isMobile = (s) =&gt; {<br>    return /^1[0-9]{10}$/.test(s)<br>}<br>3.电话号码</p>
<p>export const isPhone = (s) =&gt; {<br>    return /^([0-9]{3,4}-)?[0-9]{7,8}$/.test(s)<br>}<br>4.是否url地址</p>
<p>export const isURL = (s) =&gt; {<br>    return /^http[s]?://.*/.test(s)<br>}<br>5.是否字符串</p>
<p>export const isString = (o) =&gt; {<br>    return Object.prototype.toString.call(o).slice(8, -1) === ‘String’<br>}<br>6.是否数字</p>
<p>export const isNumber = (o) =&gt; {<br>    return Object.prototype.toString.call(o).slice(8, -1) === ‘Number’<br>}<br>7.是否boolean</p>
<p>export const isBoolean = (o) =&gt; {<br>    return Object.prototype.toString.call(o).slice(8, -1) === ‘Boolean’<br>}<br>8.是否函数</p>
<p>export const isFunction = (o) =&gt; {<br>    return Object.prototype.toString.call(o).slice(8, -1) === ‘Function’<br>}<br>9.是否为null</p>
<p>export const isNull = (o) =&gt; {<br>    return Object.prototype.toString.call(o).slice(8, -1) === ‘Null’<br>}<br>10.是否undefined</p>
<p>export const isUndefined = (o) =&gt; {<br>    return Object.prototype.toString.call(o).slice(8, -1) === ‘Undefined’<br>}<br>11.是否对象</p>
<p>export const isObj = (o) =&gt; {<br>    return Object.prototype.toString.call(o).slice(8, -1) === ‘Object’<br>}<br>12.是否数组</p>
<p>export const isArray = (o) =&gt; {<br>    return Object.prototype.toString.call(o).slice(8, -1) === ‘Array’<br>}<br>13.是否时间</p>
<p>export const isDate = (o) =&gt; {<br>    return Object.prototype.toString.call(o).slice(8, -1) === ‘Date’<br>}<br>14.是否正则</p>
<p>export const isRegExp = (o) =&gt; {<br>    return Object.prototype.toString.call(o).slice(8, -1) === ‘RegExp’<br>}<br>15.是否错误对象</p>
<p>export const isError = (o) =&gt; {<br>    return Object.prototype.toString.call(o).slice(8, -1) === ‘Error’<br>}<br>16.是否Symbol函数</p>
<p>export const isSymbol = (o) =&gt; {<br>    return Object.prototype.toString.call(o).slice(8, -1) === ‘Symbol’<br>}<br>17.是否Promise对象</p>
<p>export const isPromise = (o) =&gt; {<br>    return Object.prototype.toString.call(o).slice(8, -1) === ‘Promise’<br>}<br>18.是否Set对象</p>
<p>export const isSet = (o) =&gt; {<br>    return Object.prototype.toString.call(o).slice(8, -1) === ‘Set’<br>}<br>export const ua = navigator.userAgent.toLowerCase();<br>19.是否是微信浏览器</p>
<p>export const isWeiXin = () =&gt; {<br>    return ua.match(/microMessenger/i) == ‘micromessenger’<br>}<br>20.是否是移动端</p>
<p>export const isDeviceMobile = () =&gt; {<br>    return /android|webos|iphone|ipod|balckberry/i.test(ua)<br>}<br>21.是否是QQ浏览器</p>
<p>export const isQQBrowser = () =&gt; {<br>    return !!ua.match(/mqqbrowser|qzone|qqbrowser|qbwebviewtype/i)<br>}<br>22.是否是爬虫</p>
<p>export const isSpider = () =&gt; {<br>    return /adsbot|googlebot|bingbot|msnbot|yandexbot|baidubot|robot|careerbot|seznambot|bot|baiduspider|jikespider|symantecspider|scannerlwebcrawler|crawler|360spider|sosospider|sogou web sprider|sogou orion spider/.test(ua)<br>}<br>23.是否ios</p>
<p>export const isIos = () =&gt; {<br>    var u = navigator.userAgent;<br>    if (u.indexOf(‘Android’) &gt; -1 || u.indexOf(‘Linux’) &gt; -1) {  //安卓手机<br>        return false<br>    } else if (u.indexOf(‘iPhone’) &gt; -1) {//苹果手机<br>        return true<br>    } else if (u.indexOf(‘iPad’) &gt; -1) {//iPad<br>        return false<br>    } else if (u.indexOf(‘Windows Phone’) &gt; -1) {//winphone手机<br>        return false<br>    } else {<br>        return false<br>    }<br>}<br>24.是否为PC端</p>
<p>export const isPC = () =&gt; {<br>    var userAgentInfo = navigator.userAgent;<br>    var Agents = [“Android”, “iPhone”,<br>        “SymbianOS”, “Windows Phone”,<br>        “iPad”, “iPod”];<br>    var flag = true;<br>    for (var v = 0; v &lt; Agents.length; v++) {<br>        if (userAgentInfo.indexOf(Agents[v]) &gt; 0) {<br>            flag = false;<br>            break;<br>        }<br>    }<br>    return flag;<br>}<br>25.去除html标签</p>
<p>export const removeHtmltag = (str) =&gt; {<br>    return str.replace(/&lt;[^&gt;]+&gt;/g, ‘’)<br>}<br>26.获取url参数</p>
<p>export const getQueryString = (name) =&gt; {<br>    const reg = new RegExp(‘(^|&amp;)’ + name + ‘=([^&amp;]*)(&amp;|$)’, ‘i’);<br>    const search = window.location.search.split(‘?’)[1] || ‘’;<br>    const r = search.match(reg) || [];<br>    return r[2];<br>}<br>27.动态引入js</p>
<p>export const injectScript = (src) =&gt; {<br>    const s = document.createElement(‘script’);<br>    s.type = ‘text/javascript’;<br>    s.async = true;<br>    s.src = src;<br>    const t = document.getElementsByTagName(‘script’)[0];<br>    t.parentNode.insertBefore(s, t);<br>}<br>28.根据url地址下载</p>
<p>export const download = (url) =&gt; {<br>    var isChrome = navigator.userAgent.toLowerCase().indexOf(‘chrome’) &gt; -1;<br>    var isSafari = navigator.userAgent.toLowerCase().indexOf(‘safari’) &gt; -1;<br>    if (isChrome || isSafari) {<br>        var link = document.createElement(‘a’);<br>        link.href = url;<br>        if (link.download !== undefined) {<br>            var fileName = url.substring(url.lastIndexOf(‘/‘) + 1, url.length);<br>            link.download = fileName;<br>        }<br>        if (document.createEvent) {<br>            var e = document.createEvent(‘MouseEvents’);<br>            e.initEvent(‘click’, true, true);<br>            link.dispatchEvent(e);<br>            return true;<br>        }<br>    }<br>    if (url.indexOf(‘?’) === -1) {<br>        url += ‘?download’;<br>    }<br>    window.open(url, ‘_self’);<br>    return true;<br>}<br>29.el是否包含某个class</p>
<p>export const hasClass = (el, className) =&gt; {<br>    let reg = new RegExp(‘(^|\s)’ + className + ‘(\s|$)’)<br>    return reg.test(el.className)<br>}<br>30.el添加某个class</p>
<p>export const addClass = (el, className) =&gt; {<br>    if (hasClass(el, className)) {<br>        return<br>    }<br>    let newClass = el.className.split(‘ ‘)<br>    newClass.push(className)<br>    el.className = newClass.join(‘ ‘)<br>}<br>31.el去除某个class</p>
<p>export const removeClass = (el, className) =&gt; {<br>    if (!hasClass(el, className)) {<br>        return<br>    }<br>    let reg = new RegExp(‘(^|\s)’ + className + ‘(\s|$)’, ‘g’)<br>    el.className = el.className.replace(reg, ‘ ‘)<br>}<br>32.获取滚动的坐标</p>
<p>export const getScrollPosition = (el = window) =&gt; ({<br>    x: el.pageXOffset !== undefined ? el.pageXOffset : el.scrollLeft,<br>    y: el.pageYOffset !== undefined ? el.pageYOffset : el.scrollTop<br>});<br>33.滚动到顶部</p>
<p>export const scrollToTop = () =&gt; {<br>    const c = document.documentElement.scrollTop || document.body.scrollTop;<br>    if (c &gt; 0) {<br>        window.requestAnimationFrame(scrollToTop);<br>        window.scrollTo(0, c - c / 8);<br>    }<br>}<br>34.el是否在视口范围内</p>
<p>export const elementIsVisibleInViewport = (el, partiallyVisible = false) =&gt; {<br>    const { top, left, bottom, right } = el.getBoundingClientRect();<br>    const { innerHeight, innerWidth } = window;<br>    return partiallyVisible<br>        ? ((top &gt; 0 &amp;&amp; top &lt; innerHeight) || (bottom &gt; 0 &amp;&amp; bottom &lt; innerHeight)) &amp;&amp;<br>        ((left &gt; 0 &amp;&amp; left &lt; innerWidth) || (right &gt; 0 &amp;&amp; right &lt; innerWidth))<br>        : top &gt;= 0 &amp;&amp; left &gt;= 0 &amp;&amp; bottom &lt;= innerHeight &amp;&amp; right &lt;= innerWidth;<br>}<br>35.洗牌算法随机</p>
<p>export const shuffle = (arr) =&gt; {<br>    var result = [],<br>        random;<br>    while (arr.length &gt; 0) {<br>        random = Math.floor(Math.random() * arr.length);<br>        result.push(arr[random])<br>        arr.splice(random, 1)<br>    }<br>    return result;<br>}<br>36.劫持粘贴板</p>
<p>export const copyTextToClipboard = (value) =&gt; {<br>    var textArea = document.createElement(“textarea”);<br>    textArea.style.background = ‘transparent’;<br>    textArea.value = value;<br>    document.body.appendChild(textArea);<br>    textArea.select();<br>    try {<br>        var successful = document.execCommand(‘copy’);<br>    } catch (err) {<br>        console.log(‘Oops, unable to copy’);<br>    }<br>    document.body.removeChild(textArea);<br>}<br>37.判断类型集合</p>
<p>export const checkStr = (str, type) =&gt; {<br>    switch (type) {<br>        case ‘phone’:   //手机号码<br>            return /^1[3|4|5|6|7|8|9][0-9]{9}$/.test(str);<br>        case ‘tel’:     //座机<br>            return /^(0\d{2,3}-\d{7,8})(-\d{1,4})?$/.test(str);<br>        case ‘card’:    //身份证<br>            return /(^\d{15}$)|(^\d{18}$)|(^\d{17}(\d|X|x)$)/.test(str);<br>        case ‘pwd’:     //密码以字母开头，长度在6<del>18之间，只能包含字母、数字和下划线<br>            return /^[a-zA-Z]\w{5,17}$/.test(str)<br>        case ‘postal’:  //邮政编码<br>            return /[1-9]\d{5}(?!\d)/.test(str);<br>        case ‘QQ’:      //QQ号<br>            return /^[1-9][0-9]{4,9}$/.test(str);<br>        case ‘email’:   //邮箱<br>            return /^[\w-]+(.[\w-]+)<em>@[\w-]+(.[\w-]+)+$/.test(str);<br>        case ‘money’:   //金额(小数点2位)<br>            return /^\d</em>(?:.\d{0,2})?$/.test(str);<br>        case ‘URL’:     //网址<br>            return /(http|ftp|https)://[\w-<em>]+(.[\w-</em>]+)+([\w-.,@?^=%&amp;:/</del>+#]<em>[\w-@?^=%&amp;/~+#])?/.test(str)<br>        case ‘IP’:      //IP<br>            return /((?:(?:25[0-5]|2[0-4]\d|[01]?\d?\d)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d?\d))/.test(str);<br>        case ‘date’:    //日期时间<br>            return /^(\d{4})-(\d{2})-(\d{2}) (\d{2})(?::\d{2}|:(\d{2}):(\d{2}))$/.test(str) || /^(\d{4})-(\d{2})-(\d{2})$/.test(str)<br>        case ‘number’:  //数字<br>            return /^[0-9]$/.test(str);<br>        case ‘english’: //英文<br>            return /^[a-zA-Z]+$/.test(str);<br>        case ‘chinese’: //中文<br>            return /^[\u4E00-\u9FA5]+$/.test(str);<br>        case ‘lower’:   //小写<br>            return /^[a-z]+$/.test(str);<br>        case ‘upper’:   //大写<br>            return /^[A-Z]+$/.test(str);<br>        case ‘HTML’:    //HTML标记<br>            return /&lt;(“[^”]*”|’[^’]*’|[^’”&gt;])</em>&gt;/.test(str);<br>        default:<br>            return true;<br>    }<br>}<br>38.严格的身份证校验</p>
<p>export const isCardID = (sId) =&gt; {<br>    if (!/(^\d{15}$)|(^\d{17}(\d|X|x)$)/.test(sId)) {<br>        console.log(‘你输入的身份证长度或格式错误’)<br>        return false<br>    }<br>    //身份证城市<br>    var aCity = { 11: “北京”, 12: “天津”, 13: “河北”, 14: “山西”, 15: “内蒙古”, 21: “辽宁”, 22: “吉林”, 23: “黑龙江”, 31: “上海”, 32: “江苏”, 33: “浙江”, 34: “安徽”, 35: “福建”, 36: “江西”, 37: “山东”, 41: “河南”, 42: “湖北”, 43: “湖南”, 44: “广东”, 45: “广西”, 46: “海南”, 50: “重庆”, 51: “四川”, 52: “贵州”, 53: “云南”, 54: “西藏”, 61: “陕西”, 62: “甘肃”, 63: “青海”, 64: “宁夏”, 65: “新疆”, 71: “台湾”, 81: “香港”, 82: “澳门”, 91: “国外” };<br>    if (!aCity[parseInt(sId.substr(0, 2))]) {<br>        console.log(‘你的身份证地区非法’)<br>        return false<br>    }</p>
<pre><code>// 出生日期验证
var sBirthday = (sId.substr(6, 4) + &quot;-&quot; + Number(sId.substr(10, 2)) + &quot;-&quot; + Number(sId.substr(12, 2))).replace(/-/g, &quot;/&quot;),
    d = new Date(sBirthday)
if (sBirthday != (d.getFullYear() + &quot;/&quot; + (d.getMonth() + 1) + &quot;/&quot; + d.getDate())) &#123;
    console.log(&#39;身份证上的出生日期非法&#39;)
    return false
&#125;

// 身份证号码校验
var sum = 0,
    weights = [7, 9, 10, 5, 8, 4, 2, 1, 6, 3, 7, 9, 10, 5, 8, 4, 2],
    codes = &quot;10X98765432&quot;
for (var i = 0; i &lt; sId.length - 1; i++) &#123;
    sum += sId[i] * weights[i];
&#125;
var last = codes[sum % 11]; //计算出来的最后一位身份证号码
if (sId[sId.length - 1] != last) &#123;
    console.log(&#39;你输入的身份证号非法&#39;)
    return false
&#125;

return true
</code></pre>
<p>}<br>39.随机数范围</p>
<p>export const random = (min, max) =&gt; {<br>    if (arguments.length === 2) {<br>        return Math.floor(min + Math.random() * ((max + 1) - min))<br>    } else {<br>        return null;<br>    }<br>}<br>40.将阿拉伯数字翻译成中文的大写数字</p>
<p>export const numberToChinese = (num) =&gt; {<br>    var AA = new Array(“零”, “一”, “二”, “三”, “四”, “五”, “六”, “七”, “八”, “九”, “十”);<br>    var BB = new Array(“”, “十”, “百”, “仟”, “萬”, “億”, “点”, “”);<br>    var a = (“” + num).replace(/(^0*)/g, “”).split(“.”),<br>        k = 0,<br>        re = “”;<br>    for (var i = a[0].length - 1; i &gt;= 0; i–) {<br>        switch (k) {<br>            case 0:<br>                re = BB[7] + re;<br>                break;<br>            case 4:<br>                if (!new RegExp(“0{4}//d{“ + (a[0].length - i - 1) + “}$”)<br>                    .test(a[0]))<br>                    re = BB[4] + re;<br>                break;<br>            case 8:<br>                re = BB[5] + re;<br>                BB[7] = BB[5];<br>                k = 0;<br>                break;<br>        }<br>        if (k % 4 == 2 &amp;&amp; a[0].charAt(i + 2) != 0 &amp;&amp; a[0].charAt(i + 1) == 0)<br>            re = AA[0] + re;<br>        if (a[0].charAt(i) != 0)<br>            re = AA[a[0].charAt(i)] + BB[k % 4] + re;<br>        k++;<br>    }</p>
<pre><code>if (a.length &gt; 1) // 加上小数部分(如果有小数部分)
&#123;
    re += BB[6];
    for (var i = 0; i &lt; a[1].length; i++)
        re += AA[a[1].charAt(i)];
&#125;
if (re == &#39;一十&#39;)
    re = &quot;十&quot;;
if (re.match(/^一/) &amp;&amp; re.length == 3)
    re = re.replace(&quot;一&quot;, &quot;&quot;);
return re;
</code></pre>
<p>}<br>41.将数字转换为大写金额</p>
<p>export const changeToChinese = (Num) =&gt; {<br>    //判断如果传递进来的不是字符的话转换为字符<br>    if (typeof Num == “number”) {<br>        Num = new String(Num);<br>    };<br>    Num = Num.replace(/,/g, “”) //替换tomoney()中的“,”<br>    Num = Num.replace(/ /g, “”) //替换tomoney()中的空格<br>    Num = Num.replace(/￥/g, “”) //替换掉可能出现的￥字符<br>    if (isNaN(Num)) { //验证输入的字符是否为数字<br>        //alert(“请检查小写金额是否正确”);<br>        return “”;<br>    };<br>    //字符处理完毕后开始转换，采用前后两部分分别转换<br>    var part = String(Num).split(“.”);<br>    var newchar = “”;<br>    //小数点前进行转化<br>    for (var i = part[0].length - 1; i &gt;= 0; i–) {<br>        if (part[0].length &gt; 10) {<br>            return “”;<br>            //若数量超过拾亿单位，提示<br>        }<br>        var tmpnewchar = “”<br>        var perchar = part[0].charAt(i);<br>        switch (perchar) {<br>            case “0”:<br>                tmpnewchar = “零” + tmpnewchar;<br>                break;<br>            case “1”:<br>                tmpnewchar = “壹” + tmpnewchar;<br>                break;<br>            case “2”:<br>                tmpnewchar = “贰” + tmpnewchar;<br>                break;<br>            case “3”:<br>                tmpnewchar = “叁” + tmpnewchar;<br>                break;<br>            case “4”:<br>                tmpnewchar = “肆” + tmpnewchar;<br>                break;<br>            case “5”:<br>                tmpnewchar = “伍” + tmpnewchar;<br>                break;<br>            case “6”:<br>                tmpnewchar = “陆” + tmpnewchar;<br>                break;<br>            case “7”:<br>                tmpnewchar = “柒” + tmpnewchar;<br>                break;<br>            case “8”:<br>                tmpnewchar = “捌” + tmpnewchar;<br>                break;<br>            case “9”:<br>                tmpnewchar = “玖” + tmpnewchar;<br>                break;<br>        }<br>        switch (part[0].length - i - 1) {<br>            case 0:<br>                tmpnewchar = tmpnewchar + “元”;<br>                break;<br>            case 1:<br>                if (perchar != 0) tmpnewchar = tmpnewchar + “拾”;<br>                break;<br>            case 2:<br>                if (perchar != 0) tmpnewchar = tmpnewchar + “佰”;<br>                break;<br>            case 3:<br>                if (perchar != 0) tmpnewchar = tmpnewchar + “仟”;<br>                break;<br>            case 4:<br>                tmpnewchar = tmpnewchar + “万”;<br>                break;<br>            case 5:<br>                if (perchar != 0) tmpnewchar = tmpnewchar + “拾”;<br>                break;<br>            case 6:<br>                if (perchar != 0) tmpnewchar = tmpnewchar + “佰”;<br>                break;<br>            case 7:<br>                if (perchar != 0) tmpnewchar = tmpnewchar + “仟”;<br>                break;<br>            case 8:<br>                tmpnewchar = tmpnewchar + “亿”;<br>                break;<br>            case 9:<br>                tmpnewchar = tmpnewchar + “拾”;<br>                break;<br>        }<br>        var newchar = tmpnewchar + newchar;<br>    }<br>    //小数点之后进行转化<br>    if (Num.indexOf(“.”) != -1) {<br>        if (part[1].length &gt; 2) {<br>            // alert(“小数点之后只能保留两位,系统将自动截断”);<br>            part[1] = part[1].substr(0, 2)<br>        }<br>        for (i = 0; i &lt; part[1].length; i++) {<br>            tmpnewchar = “”<br>            perchar = part[1].charAt(i)<br>            switch (perchar) {<br>                case “0”:<br>                    tmpnewchar = “零” + tmpnewchar;<br>                    break;<br>                case “1”:<br>                    tmpnewchar = “壹” + tmpnewchar;<br>                    break;<br>                case “2”:<br>                    tmpnewchar = “贰” + tmpnewchar;<br>                    break;<br>                case “3”:<br>                    tmpnewchar = “叁” + tmpnewchar;<br>                    break;<br>                case “4”:<br>                    tmpnewchar = “肆” + tmpnewchar;<br>                    break;<br>                case “5”:<br>                    tmpnewchar = “伍” + tmpnewchar;<br>                    break;<br>                case “6”:<br>                    tmpnewchar = “陆” + tmpnewchar;<br>                    break;<br>                case “7”:<br>                    tmpnewchar = “柒” + tmpnewchar;<br>                    break;<br>                case “8”:<br>                    tmpnewchar = “捌” + tmpnewchar;<br>                    break;<br>                case “9”:<br>                    tmpnewchar = “玖” + tmpnewchar;<br>                    break;<br>            }<br>            if (i == 0) tmpnewchar = tmpnewchar + “角”;<br>            if (i == 1) tmpnewchar = tmpnewchar + “分”;<br>            newchar = newchar + tmpnewchar;<br>        }<br>    }<br>    //替换所有无用汉字<br>    while (newchar.search(“零零”) != -1)<br>        newchar = newchar.replace(“零零”, “零”);<br>    newchar = newchar.replace(“零亿”, “亿”);<br>    newchar = newchar.replace(“亿万”, “亿”);<br>    newchar = newchar.replace(“零万”, “万”);<br>    newchar = newchar.replace(“零元”, “元”);<br>    newchar = newchar.replace(“零角”, “”);<br>    newchar = newchar.replace(“零分”, “”);<br>    if (newchar.charAt(newchar.length - 1) == “元”) {<br>        newchar = newchar + “整”<br>    }<br>    return newchar;<br>}<br>42.判断一个元素是否在数组中</p>
<p>export const contains = (arr, val) =&gt; {<br>    return arr.indexOf(val) != -1 ? true : false;<br>}<br>43.数组排序，{type} 1：从小到大 2：从大到小 3：随机</p>
<p>export const sort = (arr, type = 1) =&gt; {<br>    return arr.sort((a, b) =&gt; {<br>        switch (type) {<br>            case 1:<br>                return a - b;<br>            case 2:<br>                return b - a;<br>            case 3:<br>                return Math.random() - 0.5;<br>            default:<br>                return arr;<br>        }<br>    })<br>}<br>44.去重</p>
<p>export const unique = (arr) =&gt; {<br>    if (Array.hasOwnProperty(‘from’)) {<br>        return Array.from(new Set(arr));<br>    } else {<br>        var n = {}, r = [];<br>        for (var i = 0; i &lt; arr.length; i++) {<br>            if (!n[arr[i]]) {<br>                n[arr[i]] = true;<br>                r.push(arr[i]);<br>            }<br>        }<br>        return r;<br>    }<br>}<br>45.求两个集合的并集</p>
<p>export const union = (a, b) =&gt; {<br>    var newArr = a.concat(b);<br>    return this.unique(newArr);<br>}<br>46.求两个集合的交集</p>
<p>export const intersect = (a, b) =&gt; {<br>    var _this = this;<br>    a = this.unique(a);<br>    return this.map(a, function (o) {<br>        return _this.contains(b, o) ? o : null;<br>    });<br>}<br>47.删除其中一个元素</p>
<p>export const remove = (arr, ele) =&gt; {<br>    var index = arr.indexOf(ele);<br>    if (index &gt; -1) {<br>        arr.splice(index, 1);<br>    }<br>    return arr;<br>}<br>48.将类数组转换为数组</p>
<p>export const formArray = (ary) =&gt; {<br>    var arr = [];<br>    if (Array.isArray(ary)) {<br>        arr = ary;<br>    } else {<br>        arr = Array.prototype.slice.call(ary);<br>    };<br>    return arr;<br>}<br>49.最大值</p>
<p>export const max = (arr) =&gt; {<br>    return Math.max.apply(null, arr);<br>}<br>50.最小值</p>
<p>export const min = (arr) =&gt; {<br>    return Math.min.apply(null, arr);<br>}<br>51.求和</p>
<p>export const sum = (arr) =&gt; {<br>    return arr.reduce((pre, cur) =&gt; {<br>        return pre + cur<br>    })<br>}<br>52.平均值</p>
<p>export const average = (arr) =&gt; {<br>    return this.sum(arr) / arr.length<br>}<br>53.去除空格,type: 1-所有空格 2-前后空格 3-前空格 4-后空格</p>
<p>export const trim = (str, type) =&gt; {<br>    type = type || 1<br>    switch (type) {<br>        case 1:<br>            return str.replace(/\s+/g, “”);<br>        case 2:<br>            return str.replace(/(^\s*)|(\s*$)/g, “”);<br>        case 3:<br>            return str.replace(/(^\s*)/g, “”);<br>        case 4:<br>            return str.replace(/(\s*$)/g, “”);<br>        default:<br>            return str;<br>    }<br>}<br>54.字符转换，type: 1:首字母大写 2：首字母小写 3：大小写转换 4：全部大写 5：全部小写</p>
<p>export const changeCase = (str, type) =&gt; {<br>    type = type || 4<br>    switch (type) {<br>        case 1:<br>            return str.replace(/\b\w+\b/g, function (word) {<br>                return word.substring(0, 1).toUpperCase() + word.substring(1).toLowerCase();</p>
<pre><code>        &#125;);
    case 2:
        return str.replace(/\b\w+\b/g, function (word) &#123;
            return word.substring(0, 1).toLowerCase() + word.substring(1).toUpperCase();
        &#125;);
    case 3:
        return str.split(&#39;&#39;).map(function (word) &#123;
            if (/[a-z]/.test(word)) &#123;
                return word.toUpperCase();
            &#125; else &#123;
                return word.toLowerCase()
            &#125;
        &#125;).join(&#39;&#39;)
    case 4:
        return str.toUpperCase();
    case 5:
        return str.toLowerCase();
    default:
        return str;
&#125;
</code></pre>
<p>}<br>55.检测密码强度</p>
<p>export const checkPwd = (str) =&gt; {<br>    var Lv = 0;<br>    if (str.length &lt; 6) {<br>        return Lv<br>    }<br>    if (/[0-9]/.test(str)) {<br>        Lv++<br>    }<br>    if (/[a-z]/.test(str)) {<br>        Lv++<br>    }<br>    if (/[A-Z]/.test(str)) {<br>        Lv++<br>    }<br>    if (/[.|-|_]/.test(str)) {<br>        Lv++<br>    }<br>    return Lv;<br>}<br>56.函数节流器</p>
<p>export const debouncer = (fn, time, interval = 200) =&gt; {<br>    if (time - (window.debounceTimestamp || 0) &gt; interval) {<br>        fn &amp;&amp; fn();<br>        window.debounceTimestamp = time;<br>    }<br>}<br>57.在字符串中插入新字符串</p>
<p>export const insertStr = (soure, index, newStr) =&gt; {<br>    var str = soure.slice(0, index) + newStr + soure.slice(index);<br>    return str;<br>}<br>58.判断两个对象是否键值相同</p>
<p>export const isObjectEqual = (a, b) =&gt; {<br>    var aProps = Object.getOwnPropertyNames(a);<br>    var bProps = Object.getOwnPropertyNames(b);</p>
<pre><code>if (aProps.length !== bProps.length) &#123;
    return false;
&#125;

for (var i = 0; i &lt; aProps.length; i++) &#123;
    var propName = aProps[i];

    if (a[propName] !== b[propName]) &#123;
        return false;
    &#125;
&#125;
return true;
</code></pre>
<p>}<br>59.16进制颜色转RGBRGBA字符串</p>
<p>export const colorToRGB = (val, opa) =&gt; {</p>
<pre><code>var pattern = /^(#?)[a-fA-F0-9]&#123;6&#125;$/; //16进制颜色值校验规则
var isOpa = typeof opa == &#39;number&#39;; //判断是否有设置不透明度

if (!pattern.test(val)) &#123; //如果值不符合规则返回空字符
    return &#39;&#39;;
&#125;

var v = val.replace(/#/, &#39;&#39;); //如果有#号先去除#号
var rgbArr = [];
var rgbStr = &#39;&#39;;

for (var i = 0; i &lt; 3; i++) &#123;
    var item = v.substring(i * 2, i * 2 + 2);
    var num = parseInt(item, 16);
    rgbArr.push(num);
&#125;

rgbStr = rgbArr.join();
rgbStr = &#39;rgb&#39; + (isOpa ? &#39;a&#39; : &#39;&#39;) + &#39;(&#39; + rgbStr + (isOpa ? &#39;,&#39; + opa : &#39;&#39;) + &#39;)&#39;;
return rgbStr;
</code></pre>
<p>}<br>60.追加url参数</p>
<p>export const appendQuery = (url, key, value) =&gt; {<br>    var options = key;<br>    if (typeof options == ‘string’) {<br>        options = {};<br>        options[key] = value;<br>    }<br>    options = $.param(options);<br>    if (url.includes(‘?’)) {<br>        url += ‘&amp;’ + options<br>    } else {<br>        url += ‘?’ + options<br>    }<br>    return url;<br>}<br>作者的<a target="_blank" rel="noopener" href="https://github.com/hangjob/vue-admin/edit/master/src/utils/util.js">https://github.com/hangjob/vue-admin/edit/master/src/utils/util.js</a></p>

                
            </div>
            <hr/>

            

    <div class="reprint" id="reprint-statement">
        
            <div class="reprint__author">
                <span class="reprint-meta" style="font-weight: bold;">
                    <i class="fas fa-user">
                        文章作者:
                    </i>
                </span>
                <span class="reprint-info">
                    <a href="/jack-blog/about" rel="external nofollow noreferrer">Jack</a>
                </span>
            </div>
            <div class="reprint__type">
                <span class="reprint-meta" style="font-weight: bold;">
                    <i class="fas fa-link">
                        文章链接:
                    </i>
                </span>
                <span class="reprint-info">
                    <a href="http://blog.yishoukei.top/jack-blog/2021/03/04/%E5%B0%81%E8%A3%85%E7%9A%84JS%E5%B7%A5%E5%85%B7%E7%B1%BB%E6%95%B4%E7%90%86/">http://blog.yishoukei.top/jack-blog/2021/03/04/%E5%B0%81%E8%A3%85%E7%9A%84JS%E5%B7%A5%E5%85%B7%E7%B1%BB%E6%95%B4%E7%90%86/</a>
                </span>
            </div>
            <div class="reprint__notice">
                <span class="reprint-meta" style="font-weight: bold;">
                    <i class="fas fa-copyright">
                        版权声明:
                    </i>
                </span>
                <span class="reprint-info">
                    本博客所有文章除特別声明外，均采用
                    <a href="https://creativecommons.org/licenses/by/4.0/deed.zh" rel="external nofollow noreferrer" target="_blank">CC BY 4.0</a>
                    许可协议。转载请注明来源
                    <a href="/jack-blog/about" target="_blank">Jack</a>
                    !
                </span>
            </div>
        
    </div>

    <script async defer>
      document.addEventListener("copy", function (e) {
        let toastHTML = '<span>复制成功，请遵循本文的转载规则</span><button class="btn-flat toast-action" onclick="navToReprintStatement()" style="font-size: smaller">查看</a>';
        M.toast({html: toastHTML})
      });

      function navToReprintStatement() {
        $("html, body").animate({scrollTop: $("#reprint-statement").offset().top - 80}, 800);
      }
    </script>



            <div class="tag_share" style="display: block;">
                <div class="post-meta__tag-list" style="display: inline-block;">
                    
                        <div class="article-tag">
                            
                                <a href="/jack-blog/tags/js/">
                                    <span class="chip bg-color">js</span>
                                </a>
                            
                        </div>
                    
                </div>
                <div class="post_share" style="zoom: 80%; width: fit-content; display: inline-block; float: right; margin: -0.15rem 0;">
                    <link rel="stylesheet" type="text/css" href="/jack-blog/libs/share/css/share.min.css">
<div id="article-share">

    
    <div class="social-share" data-sites="twitter,facebook,google,qq,qzone,wechat,weibo,douban,linkedin" data-wechat-qrcode-helper="<p>微信扫一扫即可分享！</p>"></div>
    <script src="/jack-blog/libs/share/js/social-share.min.js"></script>
    

    

</div>

                </div>
            </div>
            
                <style>
    #reward {
        margin: 40px 0;
        text-align: center;
    }

    #reward .reward-link {
        font-size: 1.4rem;
        line-height: 38px;
    }

    #reward .btn-floating:hover {
        box-shadow: 0 6px 12px rgba(0, 0, 0, 0.2), 0 5px 15px rgba(0, 0, 0, 0.2);
    }

    #rewardModal {
        width: 320px;
        height: 350px;
    }

    #rewardModal .reward-title {
        margin: 15px auto;
        padding-bottom: 5px;
    }

    #rewardModal .modal-content {
        padding: 10px;
    }

    #rewardModal .close {
        position: absolute;
        right: 15px;
        top: 15px;
        color: rgba(0, 0, 0, 0.5);
        font-size: 1.3rem;
        line-height: 20px;
        cursor: pointer;
    }

    #rewardModal .close:hover {
        color: #ef5350;
        transform: scale(1.3);
        -moz-transform:scale(1.3);
        -webkit-transform:scale(1.3);
        -o-transform:scale(1.3);
    }

    #rewardModal .reward-tabs {
        margin: 0 auto;
        width: 210px;
    }

    .reward-tabs .tabs {
        height: 38px;
        margin: 10px auto;
        padding-left: 0;
    }

    .reward-content ul {
        padding-left: 0 !important;
    }

    .reward-tabs .tabs .tab {
        height: 38px;
        line-height: 38px;
    }

    .reward-tabs .tab a {
        color: #fff;
        background-color: #ccc;
    }

    .reward-tabs .tab a:hover {
        background-color: #ccc;
        color: #fff;
    }

    .reward-tabs .wechat-tab .active {
        color: #fff !important;
        background-color: #22AB38 !important;
    }

    .reward-tabs .alipay-tab .active {
        color: #fff !important;
        background-color: #019FE8 !important;
    }

    .reward-tabs .reward-img {
        width: 210px;
        height: 210px;
    }
</style>

<div id="reward">
    <a href="#rewardModal" class="reward-link modal-trigger btn-floating btn-medium waves-effect waves-light red">赏</a>

    <!-- Modal Structure -->
    <div id="rewardModal" class="modal">
        <div class="modal-content">
            <a class="close modal-close"><i class="fas fa-times"></i></a>
            <h4 class="reward-title">你的赏识是我前进的动力</h4>
            <div class="reward-content">
                <div class="reward-tabs">
                    <ul class="tabs row">
                        <li class="tab col s6 alipay-tab waves-effect waves-light"><a href="#alipay">支付宝</a></li>
                        <li class="tab col s6 wechat-tab waves-effect waves-light"><a href="#wechat">微 信</a></li>
                    </ul>
                    <div id="alipay">
                        <img src="/jack-blog/medias/reward/alipay.jpg" class="reward-img" alt="支付宝打赏二维码">
                    </div>
                    <div id="wechat">
                        <img src="/jack-blog/medias/reward/wechat.png" class="reward-img" alt="微信打赏二维码">
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>

<script>
    $(function () {
        $('.tabs').tabs();
    });
</script>

            
        </div>
    </div>

    

    

    

    

    

    

    

    

    

<article id="prenext-posts" class="prev-next articles">
    <div class="row article-row">
        
        <div class="article col s12 m6" data-aos="fade-up">
            <div class="article-badge left-badge text-color">
                <i class="fas fa-chevron-left"></i>&nbsp;上一篇</div>
            <div class="card">
                <a href="/jack-blog/2021/03/08/netcore%E9%A1%B9%E7%9B%AE%E5%A6%82%E4%BD%95%E5%8A%A0%E8%BD%BD%E5%A4%9A%E4%B8%AA%E7%B1%BB%E5%BA%93%EF%BC%8C%E5%85%BC%E5%AE%B9%E7%B1%BB%E5%BA%93%E7%9A%84%E6%96%B9%E5%BC%8F/">
                    <div class="card-image">
                        
                        
                        <img src="/jack-blog/medias/featureimages/10.jpg" class="responsive-img" alt="netcore项目如何加载多个类库，兼容类库的方式">
                        
                        <span class="card-title">netcore项目如何加载多个类库，兼容类库的方式</span>
                    </div>
                </a>
                <div class="card-content article-content">
                    <div class="summary block-with-text">
                        
                            
                        
                    </div>
                    <div class="publish-info">
                        <span class="publish-date">
                            <i class="far fa-clock fa-fw icon-date"></i>2021-03-08
                        </span>
                        <span class="publish-author">
                            
                            <i class="fas fa-bookmark fa-fw icon-category"></i>
                            
                            <a href="/jack-blog/categories/C/" class="post-category">
                                    C#
                                </a>
                            
                            
                        </span>
                    </div>
                </div>
                
                <div class="card-action article-tags">
                    
                    <a href="/jack-blog/tags/NetCore/">
                        <span class="chip bg-color">NetCore</span>
                    </a>
                    
                </div>
                
            </div>
        </div>
        
        
        <div class="article col s12 m6" data-aos="fade-up">
            <div class="article-badge right-badge text-color">
                下一篇&nbsp;<i class="fas fa-chevron-right"></i>
            </div>
            <div class="card">
                <a href="/jack-blog/2021/03/04/%E6%AD%A3%E5%88%99%E8%A1%A8%E8%BE%BE%E5%BC%8F%E8%87%AA%E5%B7%B1%E7%9A%84%E4%B8%80%E4%BA%9B%E7%A7%AF%E7%B4%AF/">
                    <div class="card-image">
                        
                        
                        <img src="/jack-blog/medias/featureimages/19.jpg" class="responsive-img" alt="正则表达式自己的一些积累">
                        
                        <span class="card-title">正则表达式自己的一些积累</span>
                    </div>
                </a>
                <div class="card-content article-content">
                    <div class="summary block-with-text">
                        
                            
                        
                    </div>
                    <div class="publish-info">
                            <span class="publish-date">
                                <i class="far fa-clock fa-fw icon-date"></i>2021-03-04
                            </span>
                        <span class="publish-author">
                            
                            <i class="fas fa-bookmark fa-fw icon-category"></i>
                            
                            <a href="/jack-blog/categories/%E6%AD%A3%E5%88%99/" class="post-category">
                                    正则
                                </a>
                            
                            
                        </span>
                    </div>
                </div>
                
                <div class="card-action article-tags">
                    
                    <a href="/jack-blog/tags/%E6%AD%A3%E5%88%99%E8%A1%A8%E8%BE%BE%E5%BC%8F/">
                        <span class="chip bg-color">正则表达式</span>
                    </a>
                    
                </div>
                
            </div>
        </div>
        
    </div>
</article>

</div>



<!-- 代码块功能依赖 -->
<script type="text/javascript" src="/jack-blog/libs/codeBlock/codeBlockFuction.js"></script>

<!-- 代码语言 -->

<script type="text/javascript" src="/jack-blog/libs/codeBlock/codeLang.js"></script>


<!-- 代码块复制 -->

<script type="text/javascript" src="/jack-blog/libs/codeBlock/codeCopy.js"></script>


<!-- 代码块收缩 -->

<script type="text/javascript" src="/jack-blog/libs/codeBlock/codeShrink.js"></script>


    </div>
    <div id="toc-aside" class="expanded col l3 hide-on-med-and-down">
        <div class="toc-widget card" style="background-color: white;">
            <div class="toc-title"><i class="far fa-list-alt"></i>&nbsp;&nbsp;目录</div>
            <div id="toc-content"></div>
        </div>
    </div>
</div>

<!-- TOC 悬浮按钮. -->

<div id="floating-toc-btn" class="hide-on-med-and-down">
    <a class="btn-floating btn-large bg-color">
        <i class="fas fa-list-ul"></i>
    </a>
</div>


<script src="/jack-blog/libs/tocbot/tocbot.min.js"></script>
<script>
    $(function () {
        tocbot.init({
            tocSelector: '#toc-content',
            contentSelector: '#articleContent',
            headingsOffset: -($(window).height() * 0.4 - 45),
            collapseDepth: Number('0'),
            headingSelector: 'h2, h3, h4'
        });

        // modify the toc link href to support Chinese.
        let i = 0;
        let tocHeading = 'toc-heading-';
        $('#toc-content a').each(function () {
            $(this).attr('href', '#' + tocHeading + (++i));
        });

        // modify the heading title id to support Chinese.
        i = 0;
        $('#articleContent').children('h2, h3, h4').each(function () {
            $(this).attr('id', tocHeading + (++i));
        });

        // Set scroll toc fixed.
        let tocHeight = parseInt($(window).height() * 0.4 - 64);
        let $tocWidget = $('.toc-widget');
        $(window).scroll(function () {
            let scroll = $(window).scrollTop();
            /* add post toc fixed. */
            if (scroll > tocHeight) {
                $tocWidget.addClass('toc-fixed');
            } else {
                $tocWidget.removeClass('toc-fixed');
            }
        });

        
        /* 修复文章卡片 div 的宽度. */
        let fixPostCardWidth = function (srcId, targetId) {
            let srcDiv = $('#' + srcId);
            if (srcDiv.length === 0) {
                return;
            }

            let w = srcDiv.width();
            if (w >= 450) {
                w = w + 21;
            } else if (w >= 350 && w < 450) {
                w = w + 18;
            } else if (w >= 300 && w < 350) {
                w = w + 16;
            } else {
                w = w + 14;
            }
            $('#' + targetId).width(w);
        };

        // 切换TOC目录展开收缩的相关操作.
        const expandedClass = 'expanded';
        let $tocAside = $('#toc-aside');
        let $mainContent = $('#main-content');
        $('#floating-toc-btn .btn-floating').click(function () {
            if ($tocAside.hasClass(expandedClass)) {
                $tocAside.removeClass(expandedClass).hide();
                $mainContent.removeClass('l9');
            } else {
                $tocAside.addClass(expandedClass).show();
                $mainContent.addClass('l9');
            }
            fixPostCardWidth('artDetail', 'prenext-posts');
        });
        
    });
</script>

    

</main>




    <footer class="page-footer bg-color">
    
        <link rel="stylesheet" href="/jack-blog/libs/aplayer/APlayer.min.css">
<style>
    .aplayer .aplayer-lrc p {
        
        font-size: 12px;
        font-weight: 700;
        line-height: 16px !important;
    }

    .aplayer .aplayer-lrc p.aplayer-lrc-current {
        
        font-size: 15px;
        color: #363636;
    }

    
    .aplayer.aplayer-fixed.aplayer-narrow .aplayer-body {
        left: -66px !important;
    }

    .aplayer.aplayer-fixed.aplayer-narrow .aplayer-body:hover {
        left: 0px !important;
    }

    
</style>
<div class="">
    
    <div class="row">
        <meting-js class="col l8 offset-l2 m10 offset-m1 s12"
                   server="netease"
                   type="playlist"
                   id="503838841"
                   fixed='true'
                   autoplay='false'
                   theme='#363636'
                   loop='all'
                   order='random'
                   preload='auto'
                   volume='0.7'
                   list-folded='true'
        >
        </meting-js>
    </div>
</div>

<script src="/jack-blog/libs/aplayer/APlayer.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/meting@2/dist/Meting.min.js"></script>

    
    <div class="container row center-align" style="margin-bottom: 0px !important;">
		<div class="col s12 m8 l8 copy-right">
            Copyright&nbsp;&copy;
            
                <span id="year">2019-2021</span>
            
            <span id="year">2019</span>
            <a href="/jack-blog/about" target="_blank">Jack</a>
            |&nbsp;Powered by&nbsp;<a href="https://hexo.io/" target="_blank">Hexo</a>
			|&nbsp;<img src="/jack-blog/medias/icp.png" >
			ICP证备案：<a href="https://beian.miit.gov.cn/"  style="color:#ffff9c" target="_blank">沪ICP备2021004728号-1</a>
            <br>
            
            
            
            
            
            
            <span id="busuanzi_container_site_pv">
                |&nbsp;<i class="far fa-eye"></i>&nbsp;总访问量:&nbsp;<span id="busuanzi_value_site_pv"
                    class="white-color"></span>&nbsp;次
            </span>
            
            
            <span id="busuanzi_container_site_uv">
                |&nbsp;<i class="fas fa-users"></i>&nbsp;总访问人数:&nbsp;<span id="busuanzi_value_site_uv"
                    class="white-color"></span>&nbsp;人
            </span>
            
            <br>
            
            <br>
            
        </div>
        <div class="col s12 m4 l4 social-link social-statis">
    <a href="https://github.com/sunshinehome" class="tooltipped" target="_blank" data-tooltip="访问我的GitHub" data-position="top" data-delay="50">
        <i class="fab fa-github"></i>
    </a>



    <a href="mailto:249068302@qq.com" class="tooltipped" target="_blank" data-tooltip="邮件联系我" data-position="top" data-delay="50">
        <i class="fas fa-envelope-open"></i>
    </a>







    <a href="tencent://AddContact/?fromId=50&fromSubId=1&subcmd=all&uin=249068302" class="tooltipped" target="_blank" data-tooltip="QQ联系我: 249068302" data-position="top" data-delay="50">
        <i class="fab fa-qq"></i>
    </a>





    <a href="https://www.zhihu.com/people/jack-39-2" class="tooltipped" target="_blank" data-tooltip="关注我的知乎: https://www.zhihu.com/people/jack-39-2" data-position="top" data-delay="50">
        <i class="fab fa-zhihu1">知</i>
    </a>



    <a href="/jack-blog/atom.xml" class="tooltipped" target="_blank" data-tooltip="RSS 订阅" data-position="top" data-delay="50">
        <i class="fas fa-rss"></i>
    </a>

</div>
    </div>
</footer>

<div class="progress-bar"></div>


    <!-- 搜索遮罩框 -->
<div id="searchModal" class="modal">
    <div class="modal-content">
        <div class="search-header">
            <span class="title"><i class="fas fa-search"></i>&nbsp;&nbsp;搜索</span>
            <input type="search" id="searchInput" name="s" placeholder="请输入搜索的关键字"
                   class="search-input">
        </div>
        <div id="searchResult"></div>
    </div>
</div>

<script type="text/javascript">
$(function () {
    var searchFunc = function (path, search_id, content_id) {
        'use strict';
        $.ajax({
            url: path,
            dataType: "xml",
            success: function (xmlResponse) {
                // get the contents from search data
                var datas = $("entry", xmlResponse).map(function () {
                    return {
                        title: $("title", this).text(),
                        content: $("content", this).text(),
                        url: $("url", this).text()
                    };
                }).get();
                var $input = document.getElementById(search_id);
                var $resultContent = document.getElementById(content_id);
                $input.addEventListener('input', function () {
                    var str = '<ul class=\"search-result-list\">';
                    var keywords = this.value.trim().toLowerCase().split(/[\s\-]+/);
                    $resultContent.innerHTML = "";
                    if (this.value.trim().length <= 0) {
                        return;
                    }
                    // perform local searching
                    datas.forEach(function (data) {
                        var isMatch = true;
                        var data_title = data.title.trim().toLowerCase();
                        var data_content = data.content.trim().replace(/<[^>]+>/g, "").toLowerCase();
                        var data_url = data.url;
                        data_url = data_url.indexOf('/') === 0 ? data.url : '/' + data_url;
                        var index_title = -1;
                        var index_content = -1;
                        var first_occur = -1;
                        // only match artiles with not empty titles and contents
                        if (data_title !== '' && data_content !== '') {
                            keywords.forEach(function (keyword, i) {
                                index_title = data_title.indexOf(keyword);
                                index_content = data_content.indexOf(keyword);
                                if (index_title < 0 && index_content < 0) {
                                    isMatch = false;
                                } else {
                                    if (index_content < 0) {
                                        index_content = 0;
                                    }
                                    if (i === 0) {
                                        first_occur = index_content;
                                    }
                                }
                            });
                        }
                        // show search results
                        if (isMatch) {
                            str += "<li><a href='" + data_url + "' class='search-result-title'>" + data_title + "</a>";
                            var content = data.content.trim().replace(/<[^>]+>/g, "");
                            if (first_occur >= 0) {
                                // cut out 100 characters
                                var start = first_occur - 20;
                                var end = first_occur + 80;
                                if (start < 0) {
                                    start = 0;
                                }
                                if (start === 0) {
                                    end = 100;
                                }
                                if (end > content.length) {
                                    end = content.length;
                                }
                                var match_content = content.substr(start, end);
                                // highlight all keywords
                                keywords.forEach(function (keyword) {
                                    var regS = new RegExp(keyword, "gi");
                                    match_content = match_content.replace(regS, "<em class=\"search-keyword\">" + keyword + "</em>");
                                });

                                str += "<p class=\"search-result\">" + match_content + "...</p>"
                            }
                            str += "</li>";
                        }
                    });
                    str += "</ul>";
                    $resultContent.innerHTML = str;
                });
            }
        });
    };

    searchFunc('/jack-blog/search.xml', 'searchInput', 'searchResult');
});
</script>

    <!-- 回到顶部按钮 -->
<div id="backTop" class="top-scroll">
    <a class="btn-floating btn-large waves-effect waves-light" href="#!">
        <i class="fas fa-arrow-up"></i>
    </a>
</div>


    <script src="/jack-blog/libs/materialize/materialize.min.js"></script>
    <script src="/jack-blog/libs/masonry/masonry.pkgd.min.js"></script>
    <script src="/jack-blog/libs/aos/aos.js"></script>
    <script src="/jack-blog/libs/scrollprogress/scrollProgress.min.js"></script>
    <script src="/jack-blog/libs/lightGallery/js/lightgallery-all.min.js"></script>
    <script src="/jack-blog/js/matery.js"></script>

    <!-- Baidu Analytics -->

    <!-- Baidu Push -->

<script>
    (function () {
        var bp = document.createElement('script');
        var curProtocol = window.location.protocol.split(':')[0];
        if (curProtocol === 'https') {
            bp.src = 'https://zz.bdstatic.com/linksubmit/push.js';
        } else {
            bp.src = 'http://push.zhanzhang.baidu.com/push.js';
        }
        var s = document.getElementsByTagName("script")[0];
        s.parentNode.insertBefore(bp, s);
    })();
</script>

    
    <script src="/jack-blog/libs/others/clicklove.js" async="async"></script>
    
    
    <script async src="/jack-blog/libs/others/busuanzi.pure.mini.js"></script>
    

    
    

    <!--腾讯兔小巢-->
    
    

    

    

    
    <script src="/jack-blog/libs/instantpage/instantpage.js" type="module"></script>
    


<script src="/jack-blog/live2dw/lib/L2Dwidget.min.js?094cbace49a39548bed64abff5988b05"></script><script>L2Dwidget.init({"pluginRootPath":"live2dw/","pluginJsPath":"lib/","pluginModelPath":"assets/","tagMode":false,"debug":false,"model":{"jsonPath":"/jack-blog/live2dw/assets/miku.model.json"},"display":{"position":"right","width":270,"height":400},"mobile":{"show":false},"log":false});</script></body>

</html>
